/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.mailbox.Comment;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.service.util.ItemId;
/*    */ import com.zimbra.cs.service.util.ItemIdFormatter;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.HashSet;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetComments
/*    */   extends MailDocumentHandler
/*    */ {
/* 35 */   private static final String[] PARENT_ID_PATH = { "comment", "parentId" };
/*    */   
/*    */ 
/* 38 */   protected String[] getProxiedIdPath(Element request) { return PARENT_ID_PATH; }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException {
/* 41 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 42 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 43 */     OperationContext octxt = getOperationContext(zsc, context);
/* 44 */     ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
/*    */     
/* 46 */     Element c = request.getElement("comment");
/* 47 */     String itemId = c.getAttribute("parentId");
/*    */     
/* 49 */     ItemId iid = new ItemId(itemId, zsc);
/*    */     
/* 51 */     Element response = zsc.createElement(MailConstants.GET_COMMENTS_RESPONSE);
/* 52 */     HashSet<Account> accounts = new HashSet();
/* 53 */     for (Comment comment : mbox.getComments(octxt, iid.getId(), 0, -1)) {
/* 54 */       accounts.add(comment.getCreatorAccount());
/* 55 */       ToXML.encodeComment(response, ifmt, octxt, comment);
/*    */     }
/*    */     
/* 58 */     for (Account a : accounts) {
/* 59 */       Element user = response.addElement("user");
/* 60 */       user.addAttribute("id", a.getId());
/* 61 */       user.addAttribute("email", a.getName());
/* 62 */       user.addAttribute("name", a.getDisplayName());
/*    */     }
/* 64 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetComments.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */